import request from '../index'

interface Iuser {
    userName:string,
    passWord:string,
    name:string,
    role:string
}

interface IuserPass {
    userName:string,
    passWord:string,
    emailCode:number
}

export interface IPage {
    page:number,
    pageSize?:number
}

interface IValues {
    name?:string,
    status?:string
}

export function login(userDate:Iuser){
    return request({
        url:"user/login",
        data:userDate
    })
}

// 获取用户信息
export function getUserInfo(pageConfig:IPage,values?:IValues){
    return request({
        url:'user/info',
        data:{
            values,
            pageConfig
        }
    })
}
export function addtUserInfo(user:Iuser){
    return request({
        url:'user/add',
        data:user
    })
}
export function editUserInfo(user:Iuser){
    return request({
        url:'user/edit',
        data:user
    })
}

export function delUserInfo(Id:number){
    return request({
        url:'user/delete',
        data:{
            Id
        }
    })
}

// 获取用户菜单权限
export function getUserMenu(role:string) {
    return request({
        url:"user/menuPerms",
        data:{
            role
        }
    })
}

// 获取用户按钮权限
export function getUserbtn(role:string) {
    return request({
        url:"user/btnPower",
        data:{
            role
        }
    })
}


// 获取邮箱验证码
export function getUserEmailCode(userName:string) {
    return request({
        url:"user/userEmailCode",
        data:{
            userName
        }
    })
}


// 修改用户密码
export function editUserPass(dataSource:IuserPass) {
    return request({
        url:"user/editPassword",
        data:dataSource
    })
}

// 修改用户的状态
export function editUserSta(status:string,Id:number) {
    return request({
        url:"user/editUserSta",
        data:{
            status,
            Id
        }
    })
}
